package org.finesys.chat.core.base.embedding.store.pgvector.constants;

/**
 * 索引类型枚举
 * <p>
 * vector - up to 2,000 dimensions
 * halfvec - up to 4,000 dimensions
 * bit - up to 64,000 dimensions
 * sparsevec - up to 1,000 non-zero elements
 * <p>
 * <p>
 * m - the max number of connections per layer (16 by default)
 * ef_construction - the size of the dynamic candidate list for constructing the graph (64 by default)
 * <p>
 * CREATE INDEX ON items USING hnsw (embedding vector_l2_ops) WITH (m = 16, ef_construction = 64);
 * <p>
 * Specify the size of the dynamic candidate list for search (40 by default)
 * SET hnsw.ef_search = 100;
 * <p>
 * <p>
 * Index Build Time:
 * SET maintenance_work_mem = '8GB';
 * SET max_parallel_maintenance_workers = 7; -- plus leader
 * index process:
 * SELECT phase, round(100.0 * blocks_done / nullif(blocks_total, 0), 1) AS "%" FROM pg_stat_progress_create_index;
 */
public enum HSNWIndexEnum {

    L2_DISTANCE("vector_l2_ops", "L2 distance"),
    INNER_PRODUCT("vector_ip_ops", "Inner product"),
    COSINE_DISTANCE("vector_cosine_ops", "Cosine distance"),
    L1_DISTANCE("vector_l1_ops", "L1 distance"),
    HAMMING_DISTANCE("bit_hamming_ops", "Hamming distance"),
    JACCARD_DISTANCE("bit_jaccard_ops", "Jaccard distance");

    private String value;
    private String name;

    HSNWIndexEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }
}
